﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace jmwqz
{
    public partial class editaddr : System.Web.UI.Page
    {
        private Maticsoft.BLL.wx_shop_user_addr baddr = new Maticsoft.BLL.wx_shop_user_addr();
        private Maticsoft.Model.wx_shop_user_addr madder = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    int userid = Convert.ToInt32(Session["userid"].ToString());
                    if (!IsPostBack)
                    {
                        DataSet ds = baddr.GetList(" wid=" + userid);
                        if (Maticsoft.Common.Util2.CheckDataSet(ds))
                        {
                            List<Maticsoft.Model.wx_shop_user_addr> list = baddr.DataTableToList(ds.Tables[0]);
                            if (list != null && list.Count > 0)
                            {
                                madder = list[0];
                            }
                        }
                    }
                }
            }
            catch
            {
               
            }
  
        }

        public string GetAddrID()
        {
            if (madder != null)
            {
                return madder.id.ToString();
            }
            return "";
        }
        #region 地区绑定
        /// <summary>
        /// 绑定省份
        /// </summary>
        /// <param name="ddl"></param>
        //public void BindDdlProvince(DropDownList ddl)
        //{
        //    Maticsoft.BLL.pre_common_district disBll = new Maticsoft.BLL.pre_common_district();
        //    IList<Maticsoft.Model.pre_common_district> disList = disBll.GetModelList("level=1");
        //    if (disList != null)
        //    {
        //        ddl.DataTextField = "name";
        //        ddl.DataValueField = "id";
        //        ddl.DataSource = disList;
        //        ddl.DataBind();
        //    }

        //}

        ///// <summary>
        ///// 绑定省份
        ///// </summary>
        ///// <param name="ddl"></param>
        //public void BindDdlCity(DropDownList ddl)
        //{
        //    Maticsoft.BLL.pre_common_district disBll = new Maticsoft.BLL.pre_common_district();
        //    IList<Maticsoft.Model.pre_common_district> disList = disBll.GetModelList("level=2");
        //    if (disList != null)
        //    {
        //        ddl.DataTextField = "name";
        //        ddl.DataValueField = "id";
        //        ddl.DataSource = disList;
        //        ddl.DataBind();
        //    }

        //}

        ///// <summary>
        ///// 省级选择完以后，联动带出城市
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //protected void ddlProvince_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    string provId = ddlProvince.SelectedItem.Value;
        //    Maticsoft.BLL.pre_common_district disBll = new Maticsoft.BLL.pre_common_district();
        //    IList<Maticsoft.Model.pre_common_district> disList = disBll.GetModelList("level=2 and upid=" + provId);
        //    if (disList != null)
        //    {
        //        ddlCity.DataTextField = "name";
        //        ddlCity.DataValueField = "id";
        //        ddlCity.DataSource = disList;
        //        ddlCity.DataBind();
        //    }
        //    MessageBox.ResponseScript(this, "$(\"#txtUserName\").focus();");

        //}

        #endregion
    }
}